Skip to content

Conversation

@rlubos
Copy link
Contributor

@rlubos rlubos commented Mar 27, 2025

Pull MQTT 5.0 support from upstream

manifest-pr-skip

rlubos added 16 commits March 27, 2025 09:51
…T version

It should be possible to select maximum supported MQTT version, so that
for example MQTT 5.0 features can be compiled-out in case they're not
needed.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit f31a45f)
…QTT 5.0 enabled

Add test variant which enables MQTT 5.0 support. MQTT 3.1.1 should still
work just fine in such case, so it needs to be verified that's the case.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 08f8e2f)
…ngth

The macro did not take into account the 2-byte binary data length
encoded before the actual binary data.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 1eb9a5c)
Add support for CONNECT message specified in MQTT 5.0, along with
property encoders required to encode MQTT properties which is a new
concept in MQTT 5.0. Connect and will properties can be specified by the
application in the mqtt_client structure before connecting.

Introduce a helper function which allows to verify whether MQTT 5.0 is
used or not, so that it's still possible to use MQTT 3.1 even if MQTT
5.0 support is enabled in Kconfig.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 8fe2965)
Add support for CONNACK message specified in MQTT 5.0, along with
property decoders required to decode MQTT properties. Decoded properties
are provided to the application within mqtt_connack_param structure,
accompanying the CONNACK event.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 6038676)
Add support for PUBLISH message specified in MQTT 5.0. The message
encoder and decoder were updated to support MQTT properties.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 15ad90a)
Add support for PUBACK, PUBREC, PUBREL and PUBCOMP specified in MQTT
5.0. As all of these acknowledgment packets have similar format,
introduced a common encoder/decoder to handle ACK packets.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit c21e642)
Add support for SUBSCRIBE/UNSUBSCRIBE messages specified in MQTT 5.0.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit efd795b)
Add support for SUBACK/UNSUBACK messaged specified in MQTT 5.0.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 2459ffa)
Add support for DICONNECT message specified in MQTT 5.0.
As with MQTT 5.0, the disconnect can now also be initiated by the
broker, it was needed to add decoder support for the message.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 55e1c10)
Add support for a new AUTH message introduced in MQTT 5.0.
This is a new mechanism specified by MQTT 5.0, which allows clients and
brokers for enhanced authentication in between CONNECT and CONNACK
exchange. An additional MQTT event (MQTT_EVT_AUTH) was specified which
is triggered when the AUTH packet arrives from the broker.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 1d743fa)
Add support for handling topic aliases received from the broker.
The MQTT client implementation will store received topic for further use
in case consecutive PUBLISH received from the broker contains no topic
but alias only.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit e9da3b3)
…QTT 5.0

As MQTT 5.0 allows to specify the disconnect reason in the Disconnect
packet, use this new feature to improve error notification to the
broker, according to the error guidelines in the MQTT 5.0 spec.
For most cases, a generic arbitrary mapping between errno values and
reason codes is used, however the parser can specify the disconnect
reason code manually to better handle certain corner cases (like invalid
topic alias used).

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 8935579)
…tests

Add new test suite covering MQTT 5.0 packet format.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit 347653e)
…ntation

Make sure conditionally compiled parts of the public header related to
MQTT 5.0 support are rendered by doxygen.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit f9b4e27)
MQTT 5.0 is now supported so reflect this in the library documentation.

Signed-off-by: Robert Lubos <[email protected]>
(cherry picked from commit e380473)
@rlubos rlubos requested review from jukkar and krish2718 March 27, 2025 09:07
@rlubos
Copy link
Contributor Author

rlubos commented Mar 27, 2025

@krish2718 Just FYI, this was requested by Ulf some time ago.

…ompile errors

Upstream PR #: 87741

Add some extra ifdefs around MQTT 5.0 specific structures to prevent
compiler errors due to undefined symbols in certain configurations.

Signed-off-by: Robert Lubos <[email protected]>
@sonarqubecloud
Copy link

@rlubos rlubos merged commit 1a2d42b into nrfconnect:main Mar 28, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants